using UnityEngine;
using System.Collections;

public class solarSystemGUI : MonoBehaviour 
{
	
	public GameObject buttonClickSound;
	public GameObject solarSong;
	
	public GameObject lord;
	// Use this for initialization
	void Start () {
		Instantiate(solarSong, transform.position,transform.rotation);
		lord = GameObject.FindWithTag("Lord");
	}
	
	// Update is called once per frame
	void Update () 
    {
	}
	void OnGUI()
	{
		if(lord!=null)
		{
			GUI.backgroundColor = Color.cyan;
			GUILayout.BeginArea(new Rect(0,0,Screen.height, Screen.height));
			GUILayout.BeginVertical();
			GUILayout.Space(20);
	
			//First Horizontal
			GUILayout.BeginHorizontal();
		
			for (int i = 0; i <= lord.GetComponent<levelStorage>().levelsCompletedSolarSystemOne.Length - 1; i++)
			{
				if (lord.GetComponent<levelStorage>().levelsCompletedSolarSystemOne[i])
				{
					GUILayout.Space(20);
					if(GUILayout.Button(lord.GetComponent<levelStorage>().levelNameSolarSystemOne[i], GUILayout.Width(125), GUILayout.Height(50)))
					{
						Instantiate(buttonClickSound, transform.position, transform.rotation);
						lord.GetComponent<levelStorage>().save();
						Application.LoadLevel(lord.GetComponent<levelStorage>().sceneNamesPerLevelSolarSystemOne[i]);
					}
				}
			}
			GUILayout.EndHorizontal();

			GUILayout.Space(Screen.height / 3 * 2.5f);

        //Second Horizontal
			GUILayout.BeginHorizontal();
			GUILayout.FlexibleSpace();
			if (GUILayout.Button("System Select"))
			{
				Instantiate(buttonClickSound, transform.position, transform.rotation);
				lord.GetComponent<levelStorage>().kill();
				Application.LoadLevel("solarSystemSelect");
			}
			GUILayout.FlexibleSpace();
			GUILayout.EndHorizontal();

			GUILayout.EndVertical();
			GUILayout.EndArea();
		}
	}
}
